//
//  ByUserMyRealNameSecondVC.m
//  jinpuyiyuan_ios
//
//  Created by pro on 2017/12/14.
//  Copyright © 2017年 mc. All rights reserved.
//

#import "ByUserMyRealNameSecondVC.h"

@interface ByUserMyRealNameSecondVC ()
@end

@implementation ByUserMyRealNameSecondVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"实名";
    [self addLeftBackBarButtonItem];
    [self createViews];
}

#pragma mark - create views
- (void)createViews{
    NSArray *titles = @[@"身份证正面上传",@"身份证反面上传"];
    CGFloat width = SCREEN_WIDTH - 60;
    CGFloat height = width / 2;
    CGFloat margin = 30;
    for (int i = 0; i < titles.count; i ++) {
        UIControl *bgControl = [[UIControl alloc] init];
        [self.view addSubview:bgControl];
        [bgControl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(@(30));
            if (@available(iOS 11.0,*)) {
                make.top.equalTo(self.view.mas_safeAreaLayoutGuideTop).offset(50 + (margin + height) * i);
            }else{
                make.top.equalTo(self.view.mas_top).offset(50);
            }
            make.size.mas_equalTo(CGSizeMake(width,height));
        }];
        bgControl.backgroundColor = [UIColor colorWithWhite:0.95 alpha:1];
        bgControl.layer.cornerRadius = 4.0;
        [self createContentViews:bgControl andTitle:titles[i] andBgWidth:width andBgHeight:height];
        
    }
    
    UIButton *commitButton = [[UIButton alloc] init];
    [self.view addSubview:commitButton];
    [commitButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(0));
        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH, 40));
        if (@available(iOS 11.0,*)) {
            make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom);
        }else{
            make.bottom.equalTo(self.view.mas_bottom);
        }
    }];
    [commitButton setTitle:@"提交" forState:UIControlStateNormal];
    [commitButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [commitButton setBackgroundColor:BY_THEME_COLOR];
    commitButton.titleLabel.font = FONT(14);
}

// 创建内容视图
- (void)createContentViews:(UIControl *)control andTitle:(NSString *)title andBgWidth:(CGFloat)width andBgHeight:(CGFloat)height{
    UIView *emptyView = [[UIView alloc] init];
    [control addSubview:emptyView];
    [emptyView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(0));
        make.top.equalTo(@(0));
        make.right.equalTo(@(0));
        make.bottom.equalTo(@(0));
    }];
    
    UIImageView *photoImg = [[UIImageView alloc] init];
    [emptyView addSubview:photoImg];
    [photoImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(@((height - 70) / 2));
        make.left.equalTo(@((width - 40) / 2));
        make.size.mas_equalTo(CGSizeMake(40, 40));
    }];
    photoImg.image = [UIImage imageNamed:@"My_paizhao"];
    
    UILabel *titleLabel = [[UILabel alloc] init];
    [control addSubview:titleLabel];
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(0));
        make.top.equalTo(photoImg.mas_bottom).offset(10);
        make.height.equalTo(@(20));
        make.right.equalTo(@(0));
    }];
    titleLabel.font = FONT(14);
    titleLabel.textAlignment = NSTextAlignmentCenter;
    titleLabel.text = title;
    
    UIImageView *contentImg = [[UIImageView alloc] init];
    [control addSubview:contentImg];
    [contentImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(0));
        make.top.equalTo(@(0));
        make.right.equalTo(@(0));
        make.bottom.equalTo(@(0));
    }];
    
    
}


@end
